<?php


namespace App\Extensions\Grid\Displayers;


use App\Extensions\Grid\Actions\DefaultDelete;
use Encore\Admin\Grid\Actions\Edit;

class DropdownActions extends \Encore\Admin\Grid\Displayers\DropdownActions
{

    protected $defaultClass = [Edit::class, DefaultDelete::class];

    public function append($action): DropdownActions
    {
        return $this->add($action);
    }

    public function prepend($action): DropdownActions
    {
        return $this->add($action);
    }

    public function disableDelete(bool $disable = true)
    {
        if ($disable) {
            array_delete($this->defaultClass, DefaultDelete::class);
        } elseif (!in_array(DefaultDelete::class, $this->defaultClass)) {
            $this->defaultClass[] = DefaultDelete::class;
        }

        return $this;
    }

}
